package com.gitee.feizns.web.dao.handler.meta;

import com.gitee.feizns.bean.Property;
import com.gitee.feizns.web.dao.handler.meta.annotation.CustomFill;

/**
 * @author feizns
 * @since 2019/8/4 0004
 */
public class FillGeneratorHandler extends AbstractGeneralFillInputHandler {

    @Override
    protected void handle(Property<Object, Object> prop, Object original) {
        CustomFill annotation = prop.getAnnotation(CustomFill.class);
        if ( annotation != null ) {
            try {
                FillGenerator instance = annotation.value().newInstance();
                prop.set(instance.generate(original));
            } catch (ReflectiveOperationException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
